package com.zombie.logic.object;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.zombie.logic.enums.ItemType;
import com.zombie.logic.enums.ObjectType;
import com.zombie.logic.item.Item;
import com.zombie.state.GameState;

public class ItemObject extends GameObject {

	public ItemType itemType = ItemType.ITEM;
	public int itemId;
	public long lifeTime;
	float rndSize = 0;
	boolean sizeUp = true;
	
	public ItemObject(float f, float g, Item it) {
		super(f, g);
		itemId = it.id;
		itemType = it.type;
		size.x = it.wh;
		size.y = it.wh;
		lifeTime = 60000;
		type = ObjectType.ETC;
		image = Item.items.get(itemId).image;
	}

	@Override
	public void update(float delta) {
		if (GameState.getInstance().player.distanceToObject(this) < 32){
			GameState.getInstance().player.pickup(this);
		}
		lifeTime-=delta;
		if (lifeTime <= 0)
			remove();
		
		if (sizeUp)
			rndSize+=0.2f;
		else
			rndSize-=0.2f;
		if (sizeUp && rndSize >=5)
			sizeUp = false;
		if (!sizeUp && rndSize <=-5)
			sizeUp = true;
	}

	@Override
	public void draw(SpriteBatch batch, ShapeRenderer shapeBatch) {
		super.draw(batch, shapeBatch);
//		ResourceManager.getImage(image).drawFlash(pos.x-rndSize/2-1, pos.y-rndSize/2-1, size.x+rndSize+2, size.y+rndSize+2);
//
//		ResourceManager.getImage(image).draw(pos.x-rndSize/2, pos.y-rndSize/2, size.x+rndSize, size.y+rndSize);
	}

	@Override
	public void createBody() {
		// TODO Auto-generated method stub
		
	}

}
